﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _07_DescendingOrder
{
    public static class Kata
    {
        public static int DescendingOrder(int num)
        {
            // Bust a move right here
            //var numList = num.ToString().Select(c => int.Parse(c.ToString())).ToList();
            //numList.Sort((x, y) => -x.CompareTo(y));
            //string tmpStr = "";
            //numList.ForEach(item =>
            //{
            //    tmpStr += item.ToString();
            //});
            //return int.Parse(tmpStr);

            //使用Linq的更优解
            return int.Parse(string.Concat(num.ToString().OrderByDescending(x => x)));
        }
    }

}
